<?php
/**
 * Created by PhpStorm.
 * User: lelouchms
 * Date: 2019/6/3
 * Time: 10:46
 */

namespace app\index\controller;


use app\common\library\DDingUtil;
use app\common\library\RequestUtil;
use app\common\model\Advice;
use app\common\model\Layout;
use app\common\model\Orientation;
use app\common\model\Region;
use app\common\model\SubwayLine;
use app\common\util\CommonUtil;

class Index extends Base
{

    public function initialize()
    {
        $this->allow_action = ["getSearchToolData", "advice", "getAccessToken"];
        parent::initialize();
    }

    public function advice()
    {
        $data = (new Advice())->select();
        foreach ($data as $key => $value) {
            $data[$key]['image'] = $value['image'];
        }
        return $data;
    }

    public function getSearchToolData()
    {
        //  居室
        $responseData['layoutList'] = (new Layout())->select();
        //  朝向
        $responseData['orientationList'] = (new Orientation())->select();
        //  地区
        $responseData['regionList'] = (new Region())->select();
        //  地铁线
        $responseData['subwayLineList'] = (new SubwayLine())->select();
        return $responseData;
    }

    public function getAccessToken()
    {
//        return DDingUtil::addHome([
//            "city" => "重庆市",
//            "zone" => "江北区",
//            "location" => "曾家岩地区",
//            "block" => "龙湖新一街",
//            "home_id" => "Z12346",
//            "home_name" => "测试接口",
//        ]);

//        return DDingUtil::addPassword("ZS0224","7ca64c26cc915aaf9c0a893866906ea3");
//        return DDingUtil::getHousePassword("ZS0224", "7ca64c26cc915aaf9c0a893866906ea3", "17774974894", "3001");
//        return DDingUtil::addPassword("Z12345","18623194230");

    }


}